package com.douqu.game.core.config.sprite;

import com.douqu.game.core.config.battle.SkillConfig;
import com.douqu.game.core.entity.EntityObject;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LogUtils;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2017-12-20 10:27
 */
public class SoldierStarSkill extends EntityObject {

    public int star;

    /**
     * 普通攻击
     */
    public SkillConfig defaultSkill;

    /**
     * 特性技能列表
     */
    public SkillConfig[] skills;

    private boolean loadError = false;


    public SoldierStarSkill(int soldierId, String value)
    {
        String[] strs = value.split(ConstantFactory.SEMICOLON);
        star = Integer.parseInt(strs[0]);
        defaultSkill = DataFactory.getInstance(LoadFactory.isTestLoad()).getGameObject(DataFactory.SKILL_KEY, Integer.parseInt(strs[1]));
        if(defaultSkill == null)
        {
            LogUtils.error("Load Soldier defaultSkill Error:" + strs[1] + " soldierId:" + soldierId);
            loadError = true;
        }
        skills = new SkillConfig[strs.length-2];
        for(int i = 2; i < strs.length; i++)
        {
            skills[i-2] = DataFactory.getInstance(LoadFactory.isTestLoad()).getGameObject(DataFactory.SKILL_KEY, Integer.parseInt(strs[i]));
            if(skills[i-2] == null)
            {
                LogUtils.error("Load Soldier skill Error:" + strs[i] + " soldierId:" + soldierId);
                loadError = true;
            }
        }
    }


    public boolean isLoadError()
    {
        return loadError;
    }
}
